//
//  SettingCell.m
//  IBaby
//
//  Created by ZengYuan on 14/11/24.
//  Copyright (c) 2014年 com.zhongwei. All rights reserved.
//

#import "SettingCell.h"

@implementation SettingCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        
        CGRect rec = self.frame;
        rec.size.width=kScreenWidth;
        self.frame=rec;
        
        self.textLabel.font=SETTINGCELL_FONT;
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)addBottomLine{

    if (!bottomLine) {
        bottomLine=[[HorizonLine alloc] initWithFrame:CGRectMake(0, self.bounds.size.height-0.5, kScreenWidth, 1)];
        [self addSubview:bottomLine];
        [bottomLine setLineColor:LINE_COLOR];
        bottomLine.autoresizingMask=UIViewAutoresizingFlexibleTopMargin;
    }

}


-(void)addUpperLine{
    if (!upperLine) {
        upperLine=[[HorizonLine alloc] init];
        [self addSubview:upperLine];
        [upperLine setLineColor:LINE_COLOR];
    }
    upperLine.frame = CGRectMake(0, 0, kScreenWidth
                                 , 1);
}



-(void)setRowType:(int)arowType{
    
    _rowType = arowType;
    [self addUpperLine];
    [self addBottomLine];
    
    if (self.rowType == 0) {
        bottomLine.hidden = NO;
        upperLine.hidden = NO;
        
    }else if (self.rowType == 1){
        [self addUpperLine];
        upperLine.hidden = NO;

        if (OSVersionIsAtLeastiOS7){
            bottomLine.hidden = NO;
            bottomLine.frame = CGRectMake(15, self.bounds.size.height-0.5, kScreenWidth - 15, 1);
        }
        
        
    }else if (self.rowType == 2){
        upperLine.hidden = YES;
        bottomLine.hidden = NO;
        bottomLine.frame = CGRectMake(15, self.bounds.size.height-0.5, kScreenWidth - 15, 1);
        
    }else if (self.rowType == 3){
        upperLine.hidden = YES;
        bottomLine.hidden = NO;
    }

}
 



-(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
    [super setHighlighted:highlighted animated:animated];
    
    if (highlighted)
    {
        self.backgroundColor = RGB(240, 240, 240);

        //只针对ios6
        whiteView.backgroundColor= RGB(240, 240, 240);
    }else
    {
        self.backgroundColor = [UIColor whiteColor];
        
        //只针对ios6
        whiteView.backgroundColor= [UIColor whiteColor];

    }
}


@end
